package HLLib.userControl.HLPanelPickUp;

import javax.microedition.lcdui.Image;

import HLLib.base.HLGraphics;
import HLLib.base.HLString;
import HLLib.control.HLPanel;
import HLLib.userControl.defalut.HLBundle;

public class HLChachePanel extends HLPanel {

    public static final int TEXT_Y = 8;

    public int selectColor = 0xffff00;

    public int color = 0xffecf3fd;

    Image img;

    public String name;

    public int size;

    public String rmsName;

    public int id;

    public HLChachePanel(HLBundle bundle, Image img) {
        this.width = HLLib.base.HLScreen.width;
        this.img = img;
        this.backcolor = -1;
        this.tabelStop = true;

        rmsName = bundle.getString("rmsName");
        name = bundle.getString("name");
        size = bundle.getInt("size");
        id = bundle.getInt("id");

        this.height = (short) (TEXT_Y + HLGraphics.StringHeight() + TEXT_Y);

    }

    public void Logic() {
        super.Logic();
        if (IsFocus()) {
            RefreshEvent(GetScreenX(), GetScreenY(), GAME_BUTTON_ACTION);
        }
    }

    public void Refresh() {
        super.Refresh();
    }

    public void Render(HLGraphics g) {
        // super.Render(g);
        int screenX = GetScreenX();
        int screenY = GetScreenY();
        g.FillRect(screenX, screenY, width, height, 0xffffff);
        HLString sizeZString = new HLString(size / 1024 + "k");
        if (IsFocus()) {
            g.FillRect(screenX, screenY, width, height, HLPanelGroup.SELECTED_COLOR);// d0d9f2);//0xd0ebf2);
            // g.DrawImage(new HLImage(img), screenX + width - img.getWidth() -
            // 5 - HLGraphics.StringWidth(new HLString("9999k")), screenY +
            // (height - img.getHeight() >> 1), HLGraphics_H.TRANS_NONE);
        } else {

        }
        super.Render(g);
        int offsetX = screenX;
        int offsetY = screenY;

        g.DrawStringAdjustable(new HLString(name), 0xff0000ff, 0, offsetX, offsetY, width, height, TEXT_STYLE_NORMAL, LEFT_VCENTER);
        int sizeColor = 0xffff0000;
        if (size <= 0) {
            sizeColor = 0xff00ff00;
        }
        g.DrawStringAdjustable(sizeZString, sizeColor, 0, offsetX, offsetY, width, height, TEXT_STYLE_NORMAL, RIGHT_VCENTER);

    }

}
